@echo off

set local="G:\Bank-Of-Problems"

set a=%1
if %1. == . (
  echo Usage: ^<file_with_list_of_problems^>
  set a=list.txt
)

for /F "delims= " %%i in ('type %a%') do (
  call :process %%i
)

rem 7z a problems problems

exit

:process
  echo process %1 
  call :parse %1
  set pname=%result%
  if not exist %local%\%1 (
    echo -------------- PROBLEM DOES NOT EXIST
    exit
  )
  xcopy /S /Y %local%\%1 problems\%1\ || exit
  rem call :extract_tests problems\%pname%
exit /b

:extract_tests
  pushd %1
  7z x -y tests.7z || exit
  popd
  del tests.7z
exit /b

:parse
  set tmp=%~1
  echo Parse: "%tmp%"
  for %%i in (%tmp:\= %) do (
    call :save %%i
  )
exit /b

:save
  set result=%*
exit /b
